/*
 * @Description:
 * @Version: 1.0
 * @Autor: silencc
 * @Date: 2020-08-14 09:05:20
 * @LastEditors: silencc
 * @LastEditTime: 2020-09-19 14:29:27
 */
/* eslint-disable no-unused-vars */
import {
  request,
  paramsFilter,
  RestfulApi,
  paramsToFormData
} from "@/utils/help";
export const Upload = data => {
  const formdata = paramsToFormData({
    file: data
  });
  return request("upload/qiniuupload", formdata, "post");
};

export const Login = data => request("doLogin", paramsFilter(data), "post");
export const ChangePwd = data =>
  request("/change/password", paramsFilter(data), "post");
  // 用户 接口
export { Users } from "./modules/users";
// 角色接口
export { Roles } from "./modules/roles";
// 菜单接口
export { Menus } from "./modules/menus";
// 部门接口
export { Sysdepts } from "./modules/depts";


const _apis = {};

export const getApi = key => {
  if (!_apis[key]) _apis[key] = new RestfulApi(key);
  // _apis[key] || new RestfulApi(key)
  return _apis[key];
};

export const http = ({ type, url, data }) =>
  request(url, paramsFilter(data), type);

export const requestBlob = ({ type, url, data }) =>
  request(url, { ...paramsFilter(data), responseType: "blob" }, type);
